package com.issoft.studentresitor.controller.admin;


import com.issoft.studentresitor.domain.pojo.Feitem;
import com.issoft.studentresitor.domain.pojo.Result;
import com.issoft.studentresitor.service.IFeitemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author GJH
 * @since 2025-09-17
 */
@Api("费用列表")
@RestController
@RequestMapping("/admin/feitem")
public class FeitemController {
    @Autowired
    private IFeitemService feitemService;
    /**
     * 查询所有
     */
    @ApiOperation("查询所有")
    @GetMapping
    public Result queryAll() {
        return feitemService.list() != null ? Result.success(feitemService.list()) : Result.error("没有数据");
    }
    /**
     * 新增
     */
    @ApiOperation("新增")
    @PostMapping
    public Result add(@RequestBody Feitem feitem) {
        return feitemService.save(feitem) ? Result.success("添加成功") : Result.error("添加失败");
    }
    /**
     * 修改
     */
    @ApiOperation("修改")
    @PutMapping
    public Result update(@RequestBody Feitem feitem) {
        return feitemService.updateById(feitem) ? Result.success("修改成功") : Result.error("修改失败");
    }
    /**
     * 删除
     */
    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        return feitemService.removeById(id) ? Result.success("删除成功") : Result.error("删除失败");
    }
    /**
     * id查询
     */
    @ApiOperation("id查询")
    @GetMapping("/{id}")
    public Result get(@PathVariable Integer id) {
        return feitemService.getById(id) != null ? Result.success(feitemService.getById(id)) : Result.error("没有数据");
    }

}
